Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hyperlinks to accounts and dates in HTML and FODS export #2226

Merged
merged 5 commits into from
Sep 29, 2024

Conversation

thielema
Copy link
Contributor

This adds the option --anchor to hledger-cli. If the user passes this option, then in HTML and FODS output the account and date header cells become hyperlinks to hledger-web.
If you like this feature, I add some documentation.
I could also rename the option to --base-url for consistency with hledger-web.
There is a problem though. Some special characters like + or umlauts in account names are not correctly escaped in percent URL syntax by Lucid. I do not know how to solve this correctly with Lucid and whether it is solvable with Lucid, at all.

@thielema
Copy link
Contributor Author

The feature could also be used in hledger-web. That is, in hledger-web there could be hyperlinks to auto-generated multi-balance HTML's, that link back to hledger-web.

@simonmichael
Copy link
Owner

Interesting feature!

--base-url sounds good. I assume its value will be the same as what hledger-web prints at startup ? Eg

...
with base url http://127.0.0.1:5000
...

I don't know the url escaping function offhand but it sounds resolvable. Maybe there's ideas in hledger-web.

The reverse feature (linking to static HTML reports) could be a separate PR. I'd like to have multi-period tabular reports as a normal view in hledger-web, but linking to static html reports saved in temporary files, or better, serving the static html generated in memory, might be easier.

@thielema
Copy link
Contributor Author

thielema commented Sep 12, 2024 via email

@thielema
Copy link
Contributor Author

We could also add the query from the command-line to the hyperlinks. That is, if someone restricts transactions in a certain way for the balance command, the hledger-web register page would respect these restrictions, too.

@simonmichael
Copy link
Owner

Sorry it has taken a while to get back to this, I have been backlogged.

I have no objection to this. Do you use it much ?

Is it implemented only for the balance command right now ?

@simonmichael simonmichael added A-WISH Some kind of improvement request, hare-brained proposal, or plea. balance labels Sep 25, 2024
@thielema
Copy link
Contributor Author

thielema commented Sep 25, 2024 via email

@simonmichael simonmichael added web The hledger-web tool. html The html output format. fods The FODS output format. labels Sep 25, 2024
@thielema thielema force-pushed the spreadsheet-anchor branch 2 times, most recently from 63f1671 to 53bdfe9 Compare September 25, 2024 07:29
@simonmichael
Copy link
Owner

Things added to the balance command can often also apply to the balancesheet, balancesheetequity, cashflow, and incomestatement commands; they share many options and features. Sometimes I call them collectively "balcmds".

it would see more use if integrated in hledger-web.

Oh, if the HTML balance reports were directly served within hledger-web ? I agree that would be nice.

@thielema
Copy link
Contributor Author

thielema commented Sep 25, 2024 via email

@simonmichael
Copy link
Owner

I guess supporting these commands happens in CompoundBalanceCommand.

That's right.

@thielema thielema force-pushed the spreadsheet-anchor branch 2 times, most recently from 7aa8a27 to 3cf2c09 Compare September 26, 2024 20:22
@thielema
Copy link
Contributor Author

In CompoundBalanceCommand only the --base-url option was missing. Hyperlinking accounts in HTML output now works.

@thielema
Copy link
Contributor Author

CI build fails because of missing module Hledger.Write.Html.Attribute. However, I can locally checkout the repository and the module is present and building with cabal and stack succeeds.

@thielema
Copy link
Contributor Author

The balance query is now passed to the cell anchor URLs.
For URL percentage encoding I assume I have to call an escaping function myself. Do you already import such a function from somewhere? Otherwise I think network-uri will do it.

@thielema
Copy link
Contributor Author

I think I have now resolved the URL escaping issue using the package modern-uri.
network-uri only supports String.

@simonmichael simonmichael merged commit 9cdd21b into simonmichael:master Sep 29, 2024
1 check passed
@simonmichael
Copy link
Owner

Thank you very much!

Let's try this and keep it as long as it's useful. I'll mark it experimental to start with.

@thielema
Copy link
Contributor Author

thielema commented Sep 29, 2024 via email

@simonmichael
Copy link
Owner

Nice.

The export function will not add any slash in order to support relative hyperreferences.

Could you explain this to me a bit more ?

@simonmichael
Copy link
Owner

Ie, can we make it not care whether they write a slash or not ? Where would relative links come in.

@thielema
Copy link
Contributor Author

thielema commented Sep 29, 2024 via email

@simonmichael
Copy link
Owner

I see the PR but I haven't run it locally yet and I don't quite understand. Can we eg add the trailing/separating slash automatically when needed ?

@thielema
Copy link
Contributor Author

thielema commented Sep 29, 2024 via email

@simonmichael
Copy link
Owner

That sounds great. I'd just like to not make users work harder than needed.

@simonmichael
Copy link
Owner

If possible I'd like to clean up this slash thing before the next wave of PR merges. I have a few small followups to this one. If you prefer, I can help with the slash. No urgency.

@thielema
Copy link
Contributor Author

thielema commented Sep 29, 2024 via email

@simonmichael
Copy link
Owner

Great! Uh, in what pr or branch do I find that ?

@thielema
Copy link
Contributor Author

That commit was not yet pushed. Take this one instead:
37705f3

@simonmichael
Copy link
Owner

Will do, when I figure out how. :)

@simonmichael
Copy link
Owner

Ah, I think the PR was made against your own master by mistake: thielema#3 . I can get it from there.

@thielema
Copy link
Contributor Author

thielema commented Sep 29, 2024 via email

simonmichael added a commit that referenced this pull request Sep 29, 2024
@simonmichael
Copy link
Owner

Thank you! This and followups pushed to master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-WISH Some kind of improvement request, hare-brained proposal, or plea. balance fods The FODS output format. html The html output format. web The hledger-web tool.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants